package com.example.li.service;

import com.example.li.mapper.CaseMapper;
import com.example.li.model.Case;
import com.example.li.model.Lawyer;
import com.example.li.util.ResultDTO;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class CaseService {
    @Autowired
    CaseMapper caseMapper;

    //查询案例列表service
    public List getCaseList(Case case1) {
//        PageHelper.startPage(1, 1);
        List<Case> cases = caseMapper.selectByCase(case1);
        return cases;
    }

    //添加案例
    public ResultDTO insertCase(Case case1) {
        if (case1!= null) {
            case1.setAddTime(new Date());
            int i = caseMapper.insertSelective(case1);
            return new ResultDTO().success();
        } else {
            return new ResultDTO().failure("案例不能为空!");
        }
    }

    //删除案例
    public ResultDTO deleteCase(Case case1) {
        int i = caseMapper.deleteByPrimaryKey(case1.getId());
        return new ResultDTO().success();
    }
}
